<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>嘉和一品</title>
    <link rel="stylesheet" type="text/css" href="/assets/store/css/app.css" />
    <link rel="stylesheet" type="text/css" href="/assets/store/css/iconfont.css" />

    <style type="text/css">
    html,body{
        background:#ffff;

    }

    </style>
</head>
<body class="H-theme-background-color-white">

    
    
    
    

    <div class=" winu-logo H-center-all" style="padding-top:40px;height: 90px;padding-bottom:40px;">

        <div class="H-text-align-center">
            <img  id="portrait" src="/assets/store/image/logo.png" class="H-position-relative H-display-block H-border-radius-3 H-height-90 width-120 " />
        
        </div>
        
        
    </div>

    <form  id="form" action="{:url('user/bind_table')}" method="post">
        <input type="hidden" name="code" value="{:input('code')}" />
        <div id="" class="tab-content  H-font-size-14 H-text-align-center">

            <div class="H-text-list H-flexbox-horizontal  H-theme-background-color-white  H-vertical-middle H-touch-active">
                <div class="H-flex-item H-padding-horizontal-both-10 H-font-size-16 H-padding-vertical-both-12 H-font-weight-600">{$store.sname}</div>
                <span class="H-icon H-padding-horizontal-right-5 H-display-block"></span>
            </div>


            {if condition = "$code"}
                <div class="H-flexbox-horizontal H-border-vertical-bottom-after H-padding-horizontal-both-15">
                    <span class="H-icon H-vertical-middle H-padding-horizontal-left-10">绑定桌号：</span>
                    <input name="number" type="number" onclick=" $(this).focus()" required="" value="{if condition='$row.table_id != 0' }{$row.table_id} {/if}" class="H-theme-font-color-999 H-textbox H-vertical-align-middle H-vertical-middle H-font-size-16 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-15 H-theme-background-color-transparent" placeholder="请输入桌位号" />
                </div>

                <div class="H-padding-15 H-margin-vertical-top-10  ">
                    <button type="button" onclick="bind();" class="  H-button H-width-100-percent  H-font-size-15 H-outline-none H-padding-vertical-both-15 H-padding-horizontal-both-20 H-theme-background-color4 H-theme-border-color4 H-theme-font-color-white  "> 提 交</button>
                </div>

            <div class="H-padding-15   " style="margin-top: 30px;">
                <a type="" onclick="login();" class="  H-button   H-font-size-15 H-outline-none H-padding-vertical-both-15 H-padding-horizontal-both-20 H-border-none  H-theme-font-color-333  "> 退出登录</a>
            </div>

            {else /}

            <span class="H-icon H-vertical-middle H-padding-horizontal-left-10 H-padding-vertical-both-10">已绑定桌号：</span>
            <div class="H-clear-both H-width-100-percent H-display-table H-box-sizing-border-box H-border-vertical-top-after H-border-vertical-bottom-after H-padding-vertical-both-5 H-theme-background-color-white">
                {volist name="list" id="vo"}
                    <div tapmode="" onclick='edit(this)' data-sn="{$vo['qrcode_sn']}" class="H-display-table-cell H-float-left H-box-sizing-border-box H-border-horizontal-right-after H-width-avg-2 H-center-all H-theme-background-color-white" style="min-height: 70px;">
                        <div class="H-margin-horizontal-left-8" style="width: 42px; height: 42px; ">
                            <img src="/uploads/Qrcode/{$vo.path}" class="H-display-block H-border-both H-width-100-percent H-height-100-percent">
                        </div>
                        <div class="H-flex-item H-padding-horizontal-both-10 H-vertical-middle H-overflow-hidden H-box-sizing-border-box">
                            <div class="H-max-width-100-percent">
                                <div class="H-theme-font-color-999 H-font-size-12 H-padding-vertical-top-2 H-text-show-row-1">
                                    {$vo.table_id}号桌
                                </div>
                            </div>
                        </div>
                    </div>

                {/volist}
            </div>

            <div class="H-padding-15   " style="margin-top: 20px; margin-bottom: 60px;">
                <a type="" onclick="login();" class="  H-button   H-font-size-15 H-outline-none H-padding-vertical-both-15 H-padding-horizontal-both-20 H-border-none  H-theme-font-color-333  "> 退出登录</a>
            </div>


            <div class=" H-margin-vertical-top-10  " style="width: 100%;
    position: fixed;
    bottom: 0px;">
                <button type="button" onclick="bindmsg();" class="  H-button H-width-100-percent  H-font-size-15 H-outline-none H-padding-vertical-both-15 H-padding-horizontal-both-20 H-theme-background-color4 H-theme-border-color4 H-theme-font-color-333  ">扫二维码，绑定桌位号</button>
            </div>

            {/if}




        </div>
    </form>


    
    
    

</body>

<script type="text/javascript" src="/assets/store/script/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="/assets/addons/layer_mobile/layer.js"></script>
<script type="text/javascript">

    /*'{if condition = "$code"}*/
    var stauts = "{$row.status}";
    function bind(){
        if( stauts == 2){
            //询问框
            layer.open({
                content: '当前已绑定桌位是否继续修改？'
                ,btn: ['确定', '取消']
                ,yes: function(index){
                    layer.close(index);
                    subBind();
                }
            });
        } else {
            subBind();
        }

    }
    /*{/if}*/

    function bindmsg(){
        layer.open({
            content: '请关闭页面，使用微信或浏览器扫一扫'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
    }

    function edit( el ){
        location.href = "{:url('user/index')}?code=" + $(el).attr('data-sn');
    }

    function login(){

        location.href="{:url('login/index')}";
    }
    function subBind(){
        $.ajax({
            url: "{:url('bind_table')}",
            data:  $('#form').serializeArray() ,
            method:'post',
            dataType: "json",
            success: function(ret){
                if( ret.code ==0 ){
                    layer.open({
                        content: '绑定成功'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                    setTimeout(function(){
                        location.href = "{:url('user/index')}";
                    } , 2000)
                } else {
                    layer.open({
                        content: ret.msg
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                }
            },
            error:function(){
                alert("网络连接失败，请稍后再试");
                return false;
            }
        });
    }

  


    
</script>
</html>